***Create Motivation Data and Graphs in Section 2 and Appendix***************
*******by Ana  Maria Santacreu***********************************************



use Data/CEPII_gravity, clear

sort iso3_o iso3_d year

save tempoCEPII, replace

**==========================
use Data/Industries_trade.dta, clear
drop value
bys exp imp year: egen Total_trade=sum(value) 
collapse Total, by(exp imp year)
keep exp imp year Total_trade
sort exp imp year
save tempo, replace

use Data/Industries_trade.dta, clear
drop value
keep if IP==1
bys exp imp year: egen Total_trade_T=sum(value) 
collapse Total, by(exp imp year)
sort exp imp year
merge exp imp year using tempo
drop _m
sort exp imp year
save tempo, replace


use Data/Industries_trade.dta, clear
drop value
keep if IP==0
bys exp imp year: egen Total_trade_NT=sum(value) 
collapse Total, by(exp imp year)
merge exp imp year using tempo
drop _m
rename exp iso3_o
rename imp iso3_d
replace iso3_o="ROM" if iso3_o=="ROU"
replace iso3_d="ROM" if iso3_d=="ROU"

sort iso3_o iso3_d year

merge iso3_o iso3_d year using tempoCEPII

keep if _m==3

drop _m

sort iso3_o iso3_d year

save tempo, replace

***Data on TRIPS

use Data/TRIPS_Plus_formerge.dta, clear

rename iso3_o iso3_o
rename iso3_d iso3_d
sort iso3_o iso3_d year

merge iso3_o iso3_d year using tempo
tab _m

keep if _m==3
drop _m
duplicates drop
sort iso3_o iso3_d year
save tempo, replace


***********Data on RTAs with IP provisions (from Chelala and Martinez-Zarzoso)**********

use Data/RTA_technology.dta

rename iso_o iso3_o

rename iso_d iso3_d

sort iso3_o iso3_d year

merge iso3_o iso3_d year using tempo

tab _m

drop if iso3_o==iso3_d

keep if _m==3
drop _m
sort iso3_o iso3_d year

save tempo, replace


***Use data on royalty payments***********
***This is the same dataset used for the royalties project: Satcareu (2023, RESTAT)

use Data/Master_Analysis.dta, clear

rename iso3_o iso3_o
rename iso3_d iso3_d

keep iso3_o iso3_d year royalties_m dev_o dev_d patents_d
sort iso3_o iso3_d year
merge iso3_o iso3_d year, using tempo

tab _m
keep if _m==3

drop _m


**Here I am redefining what country is a developed country and which is developing

replace dev_d=0 if iso3_d=="EST" | iso3_d=="GEO" | iso3_d=="HRV" | iso3_d=="HUN" | iso3_d=="IND" | iso3_d=="KGZ"  | iso3_d=="LTU" | iso3_d=="LVA" | iso3_d=="MEX" | iso3_d=="MUS" | iso3_d=="MYS" | iso3_d=="PHL" | iso3_d=="POL" | iso3_d=="PRT" | iso3_d=="RUS" | iso3_d=="SVK" | iso3_d=="SVN"
replace dev_o=0 if iso3_o=="EST" | iso3_o=="GEO" | iso3_o=="HRV" | iso3_o=="HUN" | iso3_o=="IND" | iso3_o=="KGZ" | iso3_o=="LTU" | iso3_o=="LVA" | iso3_o=="MEX" | iso3_o=="MUS" | iso3_o=="MYS" | iso3_o=="PHL" | iso3_o=="POL" | iso3_o=="PRT" | iso3_o=="RUS" | iso3_o=="SVK" | iso3_o=="SVN"

rename ipr_tripsplus_patents_dummy ipr_pat
rename  ipr_tripsplus_per_pta_dummy ipr_pta

sort iso3_o iso3_d year

save Data_Analysis_old.dta, replace


***Data on TRIPS from Chelala and Martinez-Zarzoso
use Data/trips.dta, clear
rename iso_o iso3_o
rename iso_d iso3_d
sort iso3_o iso3_d year 
merge iso3_o iso3_d year using Data_Analysis_old.dta
tab _m
keep if _m==3
save Data_Analysis.dta, replace


********************************************************************************
********************************************************************************
**Figure 1 in Section 2
********************************************************************************
********************************************************************************

 
**RTA tech
 
use Data_Analysis.dta, clear
sort iso3_o iso3_d year
keep iso3_o iso3_d year royalt rta_tech rta_notech patPI trips dev_o dev_d
**keep if (dev_o==1 & dev_d==0) 
**| (dev_o==0&dev_d==1)
sort iso3_o iso3_d year

by iso3_o iso3_d (year), sort: gen byte first_rtatech = sum(rta_tech) == 1  & sum(rta_tech[_n - 1]) == 0  
by iso3_o iso3_d (year), sort: gen byte first_rtatechnotech = sum(rta_notech) == 1  & sum(rta_notech[_n - 1]) == 0  
by iso3_o iso3_d (year), sort: gen byte first_trips = sum(trips) == 1  & sum(trips[_n - 1]) == 0  

**Keep only the countries with RTA tech
sort iso3_o iso3_d first_rtatech
bys iso3_o iso3_d: gen temp=first_rtatech[_N]

sort iso3_o iso3_d first_rtatech
bys iso3_o iso3_d: gen roy_rtatech=royalt/royalt[_N]
keep if temp==1

**768 pairs have RTA tech in teh period of analysis

sort iso3_o iso3_d first_rtatech
bysort iso3_o iso3_d: gen time=year[_N]
replace time=year-time

keep if (dev_o==1 & dev_d==0) 
**| (dev_o==0&dev_d==1)

collapse  (median) roy_rtatech, by(time) 
line roy time if time<10 & time >-15
 


********************************************************************************
********************************************************************************
**Figure B.1 in Online Appendix
********************************************************************************
********************************************************************************



*******************************************************************************************************************
********************Patents (INPACT-S dataset: LaBelle, Martinez-Zarzoso, Santacreu, and Yotov (2024)**************
*******************************************************************************************************************
*******************************************************************************************************************



use Data/INPACIT_IN_Quality_NEW.dta, clear

gen temp=string(isic)
gen isic_1=substr(temp,1,1)
keep if isic_1=="3" || isic_1=="2"
rename appln_auth_iso3 iso3_d
rename person_ctry_code_iso3 iso3_o
rename appln_filing_year year

keep if year>=1995
sort iso3_o 

*drop _m
save tempo, replace


insheet using Data/Development.csv, clear
drop country
rename dev dev_o
sort iso3_o
merge iso3_o using tempo
keep if _m==3
drop _m
sort iso3_d
save tempo, replace

insheet using Data/Development.csv, clear
drop country
rename dev dev_d
rename iso3_o iso3_d
keep iso3_d dev

sort iso3_d
merge iso3_d using tempo
keep if _m==3
drop _m


collapse rta_tech rta_notech dev_o dev_d  gdp_source_d  (sum) patents_applt,by(iso3_o iso3_d isic_1 year) 


sort iso3_o iso3_d year isic_1
by iso3_o iso3_d isic_1 (year), sort: gen byte first_rtatech = sum(rta_tech) == 1  & sum(rta_tech[_n - 1]) == 0  
by iso3_o iso3_d isic_1 (year), sort: gen byte first_rtanotech = sum(rta_notech) == 1  & sum(rta_notech[_n - 1]) == 0  

**Keep only the countries with RTA tech
sort iso3_o iso3_d isic_1 first_rtatech
bys iso3_o iso3_d isic_1: gen temp=first_rtatech[_N]

sort iso3_o iso3_d isic_1 first_rtatech
bys iso3_o iso3_d isic_1: gen patent_rtatech=patents/patents[_N]


**768 pairs have RTA tech in teh period of analysis

sort iso3_o iso3_d isic_1 first_rtatech year
bysort iso3_o iso3_d isic_1: gen timetest=year[_N]
gen time=year-timetest

 
 
**Keep only the countries with RTA notech
sort iso3_o iso3_d isic_1 first_rtanotech
bys iso3_o iso3_d isic_1: gen tempnotech=first_rtanotech[_N]

sort iso3_o iso3_d isic_1 first_rtanotech 
bys iso3_o iso3_d isic_1: gen patent_rtanotech=patents/patents[_N]


**768 pairs have RTA tech in teh period of analysis

sort iso3_o iso3_d isic_1 first_rtanotech 
bysort iso3_o iso3_d isic_1: gen timenotechtest=year[_N]
gen timenotech=year-timenotechtest
 
 
**keep if (dev_o==1 & dev_d==0) 
*keep if temp==1 

save Motivation_graph_patents.dta, replace

use Motivation_graph_patents, clear
keep if temp==1 & tempnotech==0
keep if (dev_o==1 & dev_d==0) 



bys iso3_o iso3_d: egen id=sum(first_rtatech)
drop if id==0
drop id

**101 pairs have only RTA tech and 130 pairs have only RTA notech and 7 have both


sort iso3_o iso3_d time


collapse (median)  patent_rtatech  , by(time isic_1) 
keep if time<10 & time >-10

sort   time

save tempo_tech, replace



use Motivation_graph_patents, clear
keep if temp==0 & tempnotech==1
keep if (dev_o==1 & dev_d==0) 


bys iso3_o iso3_d: egen id=sum(first_rtanotech)
drop if id==0
drop id

sort iso3_o iso3_d timenotech
**101 pairs have only RTA tech and 130 pairs have only RTA notech and 7 have both


collapse (median)  patent_rtanotech  , by(timenotech isic_1)  
keep if timenotech<10 & timenotech >-10 
rename time time
sort   time

save tempo_notech, replace

merge time using tempo_tech

**assert _m==3
drop if _m!=3

drop if isic=="4"

collapse  patent* , by(time)
keep if time<6 & time>-6
  line patent_rtatech time ,   lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Patents relative to year of enforcement) xtitle(Period)  legend(label(1 "RTA tech") label(2 "RTA notech")) graphregion(fcolor(white))  xline(0, lcolor(red) lwidth(thick) lpattern(solid))   || line patent_rtanotech time ,   lcolor(black) lwidth(thick) lpattern(dash)
 
graph export Figures/Graph_motivation_patent.pdf, as(pdf) replace







*******************************************************************************
********************FDI  (Data from Larch and Yotov, 2022)*********************
*******************************************************************************
*******************************************************************************



use Data/fdi.dta, clear

rename origin iso3_o 
rename destination iso3_d
keep if year>=1995
sort iso3_o 

*drop _m
save tempo, replace


insheet using Data/Development.csv, clear
drop country
rename dev dev_o
sort iso3_o
merge iso3_o using tempo
keep if _m==3
drop _m
sort iso3_d
save tempo, replace

insheet using Data/Development.csv, clear
drop country
rename dev dev_d
rename iso3_o iso3_d
keep iso3_d dev

sort iso3_d
merge iso3_d using tempo
keep if _m==3
drop _m

sort iso3_o iso3_d year
save tempo, replace

use Data_Analysis.dta, clear
keep iso3_o iso3_d year rta_tech rta_notech
sort iso3_o iso3_d year
merge iso3_o iso3_d year using tempo
keep if _m==3
drop _m




sort iso3_o iso3_d year 
by iso3_o iso3_d  (year), sort: gen byte first_rtatech = sum(rta_tech) == 1  & sum(rta_tech[_n - 1]) == 0  
by iso3_o iso3_d  (year), sort: gen byte first_rtanotech = sum(rta_notech) == 1  & sum(rta_notech[_n - 1]) == 0  

**Keep only the countries with RTA tech
sort iso3_o iso3_d  first_rtatech
bys iso3_o iso3_d : gen temp=first_rtatech[_N]

sort iso3_o iso3_d  first_rtatech
bys iso3_o iso3_d : gen fdi_rtatech=fdi/fdi[_N]

**keep if temp==1

**768 pairs have RTA tech in teh period of analysis

sort iso3_o iso3_d  first_rtatech year
bysort iso3_o iso3_d : gen timetest=year[_N]
gen time=year-timetest

 
 
**Keep only the countries with RTA notech
sort iso3_o iso3_d  first_rtanotech
bys iso3_o iso3_d : gen tempnotech=first_rtanotech[_N]

sort iso3_o iso3_d  first_rtanotech 
bys iso3_o iso3_d : gen fdi_rtanotech=fdi/fdi[_N]

**keep if tempnotech==1

**768 pairs have RTA tech in teh period of analysis

sort iso3_o iso3_d  first_rtanotech 
bysort iso3_o iso3_d : gen timenotechtest=year[_N]
gen timenotech=year-timenotechtest
 
 
**keep if (dev_o==1 & dev_d==0) 
*keep if temp==1 

save Motivation_graph_fdi.dta, replace

use Motivation_graph_fdi, clear
keep if temp==1 & tempnotech==0
keep if (dev_o==1 & dev_d==0) 



bys iso3_o iso3_d: egen id=sum(first_rtatech)
drop if id==0
drop id

**101 pairs have only RTA tech and 130 pairs have only RTA notech and 7 have both


sort iso3_o iso3_d time


collapse (median)  fdi_rtatech  , by(time ) 
keep if time<10 & time >-10

sort   time

save tempo_tech, replace



use Motivation_graph_fdi, clear
keep if temp==0 & tempnotech==1
keep if (dev_o==1 & dev_d==0) 


bys iso3_o iso3_d: egen id=sum(first_rtanotech)
drop if id==0
drop id

sort iso3_o iso3_d timenotech
**101 pairs have only RTA tech and 130 pairs have only RTA notech and 7 have both


collapse (median)  fdi_rtanotech  , by(timenotech )  
keep if timenotech<10 & timenotech >-10 
rename time time
sort   time

save tempo_notech, replace

merge time using tempo_tech

**assert _m==3
drop if _m!=3

keep if time<6 & time>-6
  line fdi_rtatech time ,   lcolor(blue) lwidth(thick) lpattern(solid) ytitle(FDI relative to year of enforcement) xtitle(Period)  legend(label(1 "RTA tech") label(2 "RTA notech")) graphregion(fcolor(white))  xline(0, lcolor(red) lwidth(thick) lpattern(solid))   || line fdi_rtanotech time ,   lcolor(black) lwidth(thick) lpattern(dash)
 
graph export Figures/Graph_motivation_fdi.pdf, as(pdf) replace




********************************************************************************
********************************************************************************
**Table A.1 in Online Appendix 
********************************************************************************
********************************************************************************



use Data_Analysis.dta, clear
drop if iso3_o=="IRL" || iso3_o=="LUX" || iso3_o=="NLD" || iso3_o=="CHE" || iso3_o=="SGP" || iso3_o=="HKG"|| iso3_o=="BEL"|| iso3_o=="PAN" || iso3_o=="MLT"|| iso3_o=="HUN"
drop if iso3_d=="IRL" || iso3_d=="LUX" || iso3_d=="NLD" || iso3_d=="CHE" || iso3_d=="SGP" || iso3_d=="HKG"|| iso3_d=="BEL"|| iso3_d=="PAN" || iso3_d=="MLT"|| iso3_d=="HUN"

****Use this as motivation: Countries with RTA with tech provisions exchange more technology



* create exporter-time and importer-time IDs
egen exp_time = group(iso3_o year)
egen imp_time = group(iso3_d year)

* create symmetric pair ID
gen c1 = iso3_o
gen c2 = iso3_d
egen asym_pair = group(c1 c2)


eststo clear
eststo: ppmlhdfe royalt rta_tech rta_notech trips, absorb(exp_time imp_time asym_pair, savefe)  
eststo: ppmlhdfe royalt rta_tech rta_notech trips patPI, noconstant absorb(exp_time imp_time asym_pair, savefe) 
eststo: ppmlhdfe Total_trade rta_tech rta_notech trips, noconstant absorb(exp_time imp_time asym_pair, savefe) 
eststo: ppmlhdfe Total_trade rta_tech rta_notech trips patPI, noconstant absorb(exp_time imp_time asym_pair, savefe) 
esttab using TableA1.tex, se pr(2) replace




********************************************************************************
********************************************************************************
**Table A.2 in Online Appendix
********************************************************************************
********************************************************************************



use Data_Analysis.dta, clear
drop if iso3_o=="IRL" || iso3_o=="LUX" || iso3_o=="NLD" || iso3_o=="CHE" || iso3_o=="SGP" || iso3_o=="HKG"|| iso3_o=="BEL"|| iso3_o=="PAN" || iso3_o=="MLT"|| iso3_o=="HUN"
drop if iso3_d=="IRL" || iso3_d=="LUX" || iso3_d=="NLD" || iso3_d=="CHE" || iso3_d=="SGP" || iso3_d=="HKG"|| iso3_d=="BEL"|| iso3_d=="PAN" || iso3_d=="MLT"|| iso3_d=="HUN"



* create exporter-time and importer-time IDs
egen exp_time = group(iso3_o year)
egen imp_time = group(iso3_d year)

* create symmetric pair ID
gen c1 = iso3_o
gen c2 = iso3_d
egen asym_pair = group(c1 c2)


gen dummytech_NS = 1 if rta_tech==1&(dev_o==1 & dev_d==0) 
replace dummytech_NS = 0 if dummytech_NS==.

gen dummytech_NN = 1 if rta_tech==1&(dev_o==1 & dev_d==1) 
replace dummytech_NN = 0 if dummytech_NN==.

gen dummytech_SN = 1 if rta_tech==1&(dev_o==0 & dev_d==1) 
replace dummytech_SN = 0 if dummytech_SN==.


gen dummytech_SS = 1 if rta_tech==1&(dev_o==0 & dev_d==0) 
replace dummytech_SS = 0 if dummytech_SS==.


gen dummynotech_NS = 1 if rta_notech==1&(dev_o==1 & dev_d==0) 
replace dummynotech_NS = 0 if dummynotech_NS==.

gen dummynotech_NN = 1 if rta_notech==1&(dev_o==1 & dev_d==1) 
replace dummynotech_NN = 0 if dummynotech_NN==.

gen dummynotech_SN = 1 if rta_notech==1&(dev_o==0 & dev_d==1) 
replace dummynotech_SN = 0 if dummynotech_SN==.


gen dummynotech_SS = 1 if rta_notech==1&(dev_o==0 & dev_d==0) 
replace dummynotech_SS = 0 if dummynotech_SS==.




gen dummytrips_NS = 1 if trips==1&(dev_o==1 & dev_d==0) 
replace dummytrips_NS = 0 if dummytrips_NS==.

gen dummytrips_NN = 1 if trips==1&(dev_o==1 & dev_d==1) 
replace dummytrips_NN = 0 if dummytrips_NN==.

gen dummytrips_SN = 1 if trips==1&(dev_o==0 & dev_d==1) 
replace dummytrips_SN = 0 if dummytrips_SN==.


gen dummytrips_SS = 1 if trips==1&(dev_o==0 & dev_d==0) 
replace dummytrips_SS = 0 if dummytrips_SS==.




gen dummypatPI_NS = 1 if patPI==1&(dev_o==1 & dev_d==0) 
replace dummypatPI_NS = 0 if dummypatPI_NS==.

gen dummypatPI_NN = 1 if patPI==1&(dev_o==1 & dev_d==1) 
replace dummypatPI_NN = 0 if dummypatPI_NN==.

gen dummypatPI_SN = 1 if patPI==1&(dev_o==0 & dev_d==1) 
replace dummypatPI_SN = 0 if dummypatPI_SN==.


gen dummypatPI_SS = 1 if patPI==1&(dev_o==0 & dev_d==0) 
replace dummypatPI_SS = 0 if dummypatPI_SS==.





eststo clear
eststo: ppmlhdfe royalt   dummytech_* dummynotech_*  dummytrips_*, absorb(exp_time imp_time asym_pair, savefe)  
eststo: ppmlhdfe Total_trade dummytech_* dummynotech_*  dummytrips_*, absorb(exp_time imp_time asym_pair, savefe)  
eststo: ppmlhdfe royalt   dummytech_* dummynotech_*  dummytrips_* dummypatPI_*, absorb(exp_time imp_time asym_pair, savefe)  
eststo: ppmlhdfe Total_trade dummytech_* dummynotech_*  dummytrips_* dummypatPI_*, absorb(exp_time imp_time asym_pair, savefe)  

esttab
esttab using TableA2.tex, se pr(2) replace


********************************************************************************
********************************************************************************
**Figure G.1 in Online Appendix
********************************************************************************
********************************************************************************



************************************************
**Studying particular countries
************************************************


use Data_Analysis.dta, clear
gen TradeTmill=Total_trade/10^6
sort iso3_o iso3_d year

 
 
  line royalt year if iso3_o=="USA" & iso3_d=="CHL",   lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Royalties paid by Chile to the U.S. (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2004, lcolor(red) lwidth(thick) lpattern(dash))  text(0.5 2005.5 "RTAtech") text(0.5 2001.5 "TRIPS")

 graph export Figures/USA_Chile_RoyaltRTA.pdf, as(pdf) replace
 
 
 line TradeT year if iso3_d=="USA" & iso3_o=="CHL",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Chile to the U.S. (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2004, lcolor(red) lwidth(thick) lpattern(dash)) text(10 2005.5 "RTAtech") text(10 2001.5 "TRIPS")

 
 graph export Figures/Chile_USA_TradeTRTA.pdf, as(pdf) replace
 

 
  line TradeT year if iso3_d=="CHL" & iso3_o=="USA",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from the U.S. to Chile (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white))  xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2004, lcolor(red) lwidth(thick) lpattern(dash)) text(20 2005.5 "RTAtech") text(20 2001.5 "TRIPS")

 
 
 graph export Figures/USA_Chile_TradeTRTA.pdf, as(pdf) replace


 line royalt year if iso3_o=="JPN" & iso3_d=="VNM",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Royalties paid by Vietnam to Japan (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2007, lcolor(black) lwidth(thick) lpattern(dash))  xline(2009, lcolor(red) lwidth(thick) lpattern(dash)) text(0.25 2010.5 "RTAtech") text(0.25 2005.5 "TRIPS")
 
 
 
 graph export Figures/Japan_Vietnam_RoyaltRTA.pdf, as(pdf) replace
 
 
line TradeT year if iso3_d=="JPN" & iso3_o=="VNM",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Vietnam to Japan (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2007, lcolor(black) lwidth(thick) lpattern(dash))  xline(2009, lcolor(red) lwidth(thick) lpattern(dash)) text(15 2010.5 "RTAtech") text(15 2005.5 "TRIPS") 
  
 
 graph export Figures/Vietnam_Japan_TradeTRTA.pdf, as(pdf) replace
 

  line TradeT year if iso3_d=="VNM" & iso3_o=="JPN",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Japan to Vietnam (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2007, lcolor(black) lwidth(thick) lpattern(dash))  xline(2009, lcolor(red) lwidth(thick) lpattern(dash)) text(10 2010.5 "RTAtech") text(10 2005.5 "TRIPS") 
 
 
 graph export Figures/Japan_Vietnam_TradeTRTA.pdf, as(pdf) replace

 

  line royalt year if iso3_o=="JPN" & iso3_d=="MYS",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Royalties paid by Malaysia to Japan (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2007, lcolor(red) lwidth(thick) lpattern(dash)) text(0.6 2008.5 "RTAtech") text(0.6 2001 "TRIPS") 

 
 graph export Figures/Japan_Malaysia_RoyaltRTA.pdf, as(pdf) replace
 
 
 
 
 line TradeT year if iso3_d=="MYS" & iso3_o=="JPN",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Japan to Malaysia (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2007, lcolor(red) lwidth(thick) lpattern(dash)) text(22 2008.5 "RTAtech") text(22 2001 "TRIPS") 
 
 
 graph export Figures/Japan_Malaysia_TradeTRTA.pdf, as(pdf) replace

 
 
 line TradeTmill year if iso3_d=="JPN" & iso3_o=="MYS",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Malysia to Japan (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2007, lcolor(red) lwidth(thick) lpattern(dash)) text(22 2008.5 "RTAtech") text(22 2001 "TRIPS") 

 graph export Figures/Malaysia_Japan_TradeTRTA.pdf, as(pdf) replace

 
 
   line royalt year if iso3_o=="SGP" & iso3_d=="CHN",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Royalties paid by China to Singapore (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2001, lcolor(black) lwidth(thick) lpattern(dash))  xline(2005, lcolor(red) lwidth(thick) lpattern(dash)) text(0.6 2006.5 "RTAtech") text(0.6 2002 "TRIPS")  
 
 
 
 graph export Figures/Singapore_China_RoyaltRTA.pdf, as(pdf) replace
 
  
  line TradeT year if iso3_d=="CHN" & iso3_o=="SGP",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Singapore to China (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2001, lcolor(black) lwidth(thick) lpattern(dash))  xline(2005, lcolor(red) lwidth(thick) lpattern(dash)) text(35 2006.5 "RTAtech") text(35 2002 "TRIPS")   
 
 
 graph export Figures/Singapore_China_TradeTRTA.pdf, as(pdf) replace

 
  
  line TradeTmill year if iso3_d=="SGP" & iso3_o=="CHN",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from China to Singapore (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2001, lcolor(black) lwidth(thick) lpattern(dash))  xline(2005, lcolor(red) lwidth(thick) lpattern(dash)) text(35 2006.5 "RTAtech") text(35 2002 "TRIPS") 
 
 graph export Figures/China_Singapore_TradeTRTA.pdf, as(pdf) replace

 
 ***********
 
 
  line royalt year if iso3_o=="AUS" & iso3_d=="MYS",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Royalties paid by Malaysia to Australia (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2010, lcolor(red) lwidth(thick) lpattern(dash)) text(0.022 2008.5 "RTAtech") text(0.022 2001 "TRIPS") 

 
 graph export Figures/Australia_Malaysia_RoyaltRTA.pdf, as(pdf) replace
 
 
  
 line TradeT year if iso3_d=="MYS" & iso3_o=="AUS",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Australia to Malaysia (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2007, lcolor(red) lwidth(thick) lpattern(dash)) text(4.5 2008.5 "RTAtech") text(4.5 2001 "TRIPS") 
 
 
 graph export Figures/Austrlia_Malaysia_TradeTRTA.pdf, as(pdf) replace

 
 
 line TradeTmill year if iso3_d=="AUS" & iso3_o=="MYS",  lcolor(blue) lwidth(thick) lpattern(solid) ytitle(Exports  from Malysia to Australia (millions USD)) xtitle(Year) legend(off) graphregion(fcolor(white)) xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2000, lcolor(black) lwidth(thick) lpattern(dash))  xline(2007, lcolor(red) lwidth(thick) lpattern(dash)) text(9 2008.5 "RTAtech") text(9 2001 "TRIPS") 

 graph export Figures/Malaysia_Australia_TradeTRTA.pdf, as(pdf) replace

 